package com.jp.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Title: Audience
 * Description:
 *
 * @author zifan_jp
 * @version 1.0
 * @since Date: 2019-11-15 15:58
 * Copyright: Copyright (c) zifan_jp
 * ModificationHistory   Who    When    What
 * -----------------------------------------------
 */


@Aspect
@Component
public class Audience {

    @Autowired
    InterfaceA interfaceA;


    @Pointcut("execution(* com.jp.aop.Performance.perform(..))")
    public void performance() {

    }
//    @Before("performance()")
//    public void before() {
//        System.out.println("before");
//    }
//
//    @After("performance()")
//    public void after() {
//        System.out.println("after");
//    }
//
//    @AfterReturning("performance()")
//    public void afterReturning() {
//        System.out.println("return");
//    }
//
//    @AfterThrowing("performance()")
//    public void afterThrow() {
//        System.out.println("throw");
//    }
    @Around("performance()")
    public void around(ProceedingJoinPoint jp){
        try {
            System.out.println("befor");
            System.out.println("methodName:"+jp.getSignature().getName());
            interfaceA.test();
            jp.proceed();
            System.out.println("after");
        }catch (Throwable e){
            System.out.println("Throw");
        }
    }


}
